{% extends 'base.html' %} {% block css%}
<style type="text/css"></style>
{% endblock %} {% block body%}
<div class="row">
    <div class="col-md-6">

        <table class="table table-hover table-condensed form-inline">
            <tr>
                <td style="font-size:12px">Register</td>
                <td style="background: #FFFFCC">
                    <input class="form-control" type="text" id="dcv_reg" style="width:90px; height:30px" placeholder="address" />
                    &nbsp;&nbsp;
                    <input class="form-control" type="text" id="dcv_reg_val" style="width:90px; height:30px" placeholder="value" />
                    &nbsp;&nbsp;
                    <span style="font-size:12px" id="txt_dcv_reg">---</span>
                </td>
                <td>
                    <button class="btn btn-success" id="btn_get_dcv_reg">
                        Get
                    </button>
                    <button class="btn btn-primary" id="btn_set_dcv_reg">
                        Set
                    </button>
                </td>
            </tr>
            <tr>
                <td style="font-size:12px">Buck1 Voltage</td>
                <td style="background: #FFFFCC">
                    <input class="form-control" type="text" id="dcv_vol1" style="width:90px; height:30px" />
                    &nbsp;&nbsp;
                    <span style="font-size:12px" id="txt_dcv_vol1">---</span>
                </td>
                <td>
                    <button class="btn btn-success" id="btn_get_dcv_vol1">
                        Get
                    </button>
                    <button class="btn btn-primary" id="btn_set_dcv_vol1">
                        Set
                    </button>
                </td>
            </tr>
            <tr>
                <td style="font-size:12px">Buck2 Voltage</td>
                <td style="background: #FFFFCC">
                    <input class="form-control" type="text" id="dcv_vol2" style="width:90px; height:30px" />
                    &nbsp;&nbsp;
                    <span style="font-size:12px" id="txt_dcv_vol2">---</span>
                </td>
                <td>
                    <button class="btn btn-success" id="btn_get_dcv_vol2">
                        Get
                    </button>
                    <button class="btn btn-primary" id="btn_set_dcv_vol2">
                        Set
                    </button>
                </td>
            </tr>
            <tr>
                <td style="font-size:12px">COSA Power</td>
                <td>
                    <select class="form-control" id="cosa_power" style="width:90px; height:30px">
                        <option value=0>OFF</option>
                        <option value=1>ON</option>
                    </select>
                </td>
                <td>
                    <!-- <button class="btn btn-success" id="btn_get_dcv_reg">
            Get
          </button> -->
                    <button class="btn btn-primary" id="btn_set_cosa_power">
                        Set
                    </button>
                </td>
            </tr>
        </table>

        <br><br>
    </div>
    <!-- end of md-8 -->

    <div class="col-md-4">

    </div>

</div>
{% endblock %} {% block js%}
{{ super() }}
<script type="text/javascript">

$(document).ready(function() {
    toastr.options = {
        "closeButton": true,
        "positionClass": "toast-top-center"
    }
    
    $("#btn_get_dcv_reg").click(function() {
        $.post(
            "api/get_dcv_reg", {
                dcv_reg: $("#dcv_reg").val()
            },
            function(data, status) {
                console.log("data: " + data);
                $("#txt_dcv_reg").html(data);
            }
        );
    });

    $("#btn_set_dcv_reg").click(function() {
        var dcv_reg = $("#dcv_reg").val();
        var dcv_reg_val = $("#dcv_reg_val").val();
        $.post(
            "api/set_dcv_reg", {
                dcv_reg: dcv_reg,
                dcv_reg_val: dcv_reg_val
            },
            function(data, status) {
                toastr["success"]("Command successfully issued.");
                console.log("data: " + data);
            }
        );
    });

    $("#btn_get_dcv_vol1").click(function() {
        $.post(
            "api/get_dcv_vol1", {
                // idx: $("#dcv_vol1").val()
            },
            function(data, status) {
                console.log("data: " + data);
                $("#txt_dcv_vol1").html(data);
            }
        );
    });

    $("#btn_set_dcv_vol1").click(function() {
        var dcv_vol1 = $("#dcv_vol1").val();
        $.post(
            "api/set_dcv_vol1", {
                dcv_vol1: dcv_vol1
            },
            function(data, status) {
                toastr["success"]("Command successfully issued.");
                console.log("data: " + data);
            }
        );
    });


    $("#btn_get_dcv_vol2").click(function() {
        $.post(
            "api/get_dcv_vol2", {
                // idx: $("#dcv_vol2").val()
            },
            function(data, status) {
                console.log("data: " + data);
                $("#txt_dcv_vol2").html(data);
            }
        );
    });

    $("#btn_set_dcv_vol2").click(function() {
        var dcv_vol2 = $("#dcv_vol2").val();
        $.post(
            "api/set_dcv_vol2", {
                dcv_vol2: dcv_vol2
            },
            function(data, status) {
                toastr["success"]("Command successfully issued.");
                console.log("data: " + data);
            }
        );
    });

    $("#btn_set_cosa_power").click(function() {
        var cosa_power = $("#cosa_power").val();
        $.post(
            "api/cosa_power", {
                cosa_power: cosa_power
            },
            function(data, status) {
                toastr["success"]("Command successfully issued.");
                console.log("data: " + data);
            }
        );
    });


});
</script>
{% endblock %}